

// $("#topBtn").click(operator("top"));
// $("#refiningBtn").click(operator("refining"));
// $("#deleteBtn").click(operator("delete"));




function like(btn, entityType, entityId, userId, postId){
    $.post(
        CONTEXT_PATH + "/like",
        {"entityType":entityType,"entityId":entityId,"userId":userId, "postId":postId},
        function(data) {
            data = $.parseJSON(data);
            if(data.code === 0){
                $(btn).children("i").text(data.map.likeCount);
                if(data.map.status === 1){
                    $(btn).children("span").text("已赞");
                }else {
                    $(btn).children("span").text("赞");
                }
            }else {
                alert(data.msg);
            }
        }
    )
}

function operator(oper) {
    id = $("#postId").val();
    $.post(
        CONTEXT_PATH + "/discuss/" + oper,
        {"id": id},
        function (data){
            data = $.parseJSON(data);
            if(data.code === 0){
                btn = oper + "Btn"
                $("#" + btn).attr("disable", "disable");
                if(oper === "delete"){
                    location.href = CONTEXT_PATH + "/index";
                }else {
                    window.location.reload();
                }
            }else {
                alert(data.msg);
            }
        }
    )

}

